package gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Rectangle;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JSpinner;
import javax.swing.ListSelectionModel;

import types.DEPT_TYPES;
import types.DAYS;
import types.TERMS;
import user.User;

import javax.swing.JButton;

public class AdminAddCourse extends JFrame {

	private JPanel contentPane;
	private JLabel crnLabel;
	private JTextField crnField;
	private JTextField titleField;
	private JTextField courseCodeField;
	private JTextField sectionField;
	private JTextField instField;
	private JTextField textField_6;
	private JTextField timeField;
	private JPanel panel;
	private JPanel panel_1;
	private JLabel titleLabel;
	private JPanel panel_2;
	private JLabel courseCodeLabel;
	private JPanel panel_3;
	private JLabel termLabel;
	private JPanel panel_4;
	private JLabel sectionLabel;
	private JPanel panel_5;
	private JLabel instLabel;
	private JPanel panel_6;
	private JPanel panel_7;
	private JLabel daysLabel;
	private JLabel creditLabel;
	private JPanel panel_8;
	private JLabel locationLabel;
	private JPanel panel_9;
	private JLabel timeLabel;
	private JPanel panel_10;
	private JLabel deptLabel;
	private JPanel panel_11;
	private JRadioButton rdbtnComputerScience;
	private JPanel panel_12;
	private JRadioButton rdbtnAerospaceEngineering;
	private JPanel panel_13;
	private JRadioButton rdbtnBiology;
	private JPanel panel_14;
	private JRadioButton rdbtnBiomedicalEngineering;
	private JRadioButton rdbtnElectricalAndComputer;
	private JPanel panel_15;
	private JPanel panel_17;
	private JPanel panel_16;
	private JPanel panel_19;
	private JPanel panel_18;
	private JList daysList;
	private JScrollPane daysScrollPane;
	private JList termsList;
	private JScrollPane termsScrollPane;
	private JButton cancelBttn;
	private JButton submitBttn;
	
	private User currUser;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					AdminAddCourse frame = new AdminAddCourse(new User("ADMIN"));
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	/**
	 * Create the frame.
	 */
	public AdminAddCourse(User currUser) {
		
		this.currUser = currUser;
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 700, 500);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new GridLayout(10, 2, 0, 0));
		
		panel = new JPanel();
		contentPane.add(panel);
		
		crnLabel = new JLabel("CRN: ");
		panel.add(crnLabel);
		
		crnField = new JTextField();
		panel.add(crnField);
		crnField.setColumns(10);
		
		panel_1 = new JPanel();
		contentPane.add(panel_1);
		
		titleLabel = new JLabel("Title: ");
		panel_1.add(titleLabel);
		
		titleField = new JTextField();
		panel_1.add(titleField);
		titleField.setColumns(10);
		
		panel_2 = new JPanel();
		contentPane.add(panel_2);
		
		courseCodeLabel = new JLabel("Course Code: ");
		panel_2.add(courseCodeLabel);
		
		courseCodeField = new JTextField();
		panel_2.add(courseCodeField);
		courseCodeField.setColumns(10);
		
		panel_3 = new JPanel();
		contentPane.add(panel_3);
		
		termLabel = new JLabel("Term: ");
		panel_3.add(termLabel);
		
		termsList = new JList(new DefaultComboBoxModel(TERMS.values()));
		termsList.setBounds(new Rectangle(0, 0, 0, 10));
		termsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		termsList.setSelectedIndex(1);
		termsList.setDoubleBuffered(true);
		termsList.setVisibleRowCount(2);
		termsList.setSelectedIndex(0);
		
		termsScrollPane = new JScrollPane(termsList);
		panel_3.add(termsScrollPane);
		
		panel_4 = new JPanel();
		contentPane.add(panel_4);
		
		sectionLabel = new JLabel("Sections: ");
		panel_4.add(sectionLabel);
		
		sectionField = new JTextField();
		panel_4.add(sectionField);
		sectionField.setColumns(10);
		
		panel_5 = new JPanel();
		contentPane.add(panel_5);
		
		instLabel = new JLabel("Instructors: ");
		panel_5.add(instLabel);
		
		instField = new JTextField();
		panel_5.add(instField);
		instField.setColumns(10);
		
		panel_6 = new JPanel();
		contentPane.add(panel_6);
		
		creditLabel = new JLabel("Credits: 3.0");
		panel_6.add(creditLabel);
		
		panel_7 = new JPanel();
		contentPane.add(panel_7);
		
		daysLabel = new JLabel("Days: ");
		panel_7.add(daysLabel);
		
		daysList = new JList(new DefaultComboBoxModel(DAYS.values()));
		daysList.setBounds(new Rectangle(0, 0, 0, 10));
		daysList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		daysList.setSelectedIndex(1);
		daysList.setDoubleBuffered(true);
		daysList.setVisibleRowCount(2);
		daysList.setSelectedIndex(0);
		
		daysScrollPane = new JScrollPane(daysList);
		panel_7.add(daysScrollPane);
		
		panel_8 = new JPanel();
		contentPane.add(panel_8);
		
		locationLabel = new JLabel("Location: ");
		panel_8.add(locationLabel);
		
		textField_6 = new JTextField();
		panel_8.add(textField_6);
		textField_6.setColumns(10);
		
		panel_9 = new JPanel();
		contentPane.add(panel_9);
		
		timeLabel = new JLabel("Time: ");
		panel_9.add(timeLabel);
		
		timeField = new JTextField();
		panel_9.add(timeField);
		timeField.setColumns(10);
		
		panel_10 = new JPanel();
		contentPane.add(panel_10);
		
		deptLabel = new JLabel("Departments: ");
		panel_10.add(deptLabel);
		
		panel_11 = new JPanel();
		contentPane.add(panel_11);
		
		rdbtnComputerScience = new JRadioButton("Computer Science");
		panel_11.add(rdbtnComputerScience);
		
		panel_12 = new JPanel();
		contentPane.add(panel_12);
		
		rdbtnAerospaceEngineering = new JRadioButton("Aerospace Engineering");
		panel_12.add(rdbtnAerospaceEngineering);
		
		panel_13 = new JPanel();
		contentPane.add(panel_13);
		
		rdbtnBiology = new JRadioButton("Biology");
		panel_13.add(rdbtnBiology);
		
		panel_14 = new JPanel();
		contentPane.add(panel_14);
		
		rdbtnBiomedicalEngineering = new JRadioButton("Biomedical Engineering");
		panel_14.add(rdbtnBiomedicalEngineering);
		
		panel_15 = new JPanel();
		contentPane.add(panel_15);
		
		rdbtnElectricalAndComputer = new JRadioButton("Electrical and Computer Engineering");
		panel_15.add(rdbtnElectricalAndComputer);
		
		panel_16 = new JPanel();
		contentPane.add(panel_16);
		
		panel_17 = new JPanel();
		contentPane.add(panel_17);
		
		panel_18 = new JPanel();
		contentPane.add(panel_18);
		
		cancelBttn = new JButton("CANCEL");
		panel_18.add(cancelBttn);
		cancelBttn.addActionListener(cancelListener);
		
		panel_19 = new JPanel();
		contentPane.add(panel_19);
		
		submitBttn = new JButton("SUBMIT");
		panel_19.add(submitBttn);
		submitBttn.addActionListener(submitListener);
	
	}
	
	
	private ActionListener submitListener = new ActionListener() {
		
		public void actionPerformed(ActionEvent arg0) {
			
		}
	};
	
	private ActionListener cancelListener = new ActionListener() {
		
		public void actionPerformed(ActionEvent arg0) {
			HomePageFrame pFrame = new HomePageFrame(currUser);
			pFrame.setVisible(true);
			AdminAddCourse.this.dispose();
		}
	};

	
}




